cmake_minimum_required(VERSION 3.10)
project(resource_optical_clip_detector)

## Compile as C++11, supported in ROS Kinetic and newer
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Debug/Release flags
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")

# Find CUDA
find_package(CUDA REQUIRED)

# Find OpenCV
find_package(OpenCV REQUIRED)

# TensorRT settings
set(TENSORRT_DIR "/home/xjl/tensorrt/TensorRT-8.5.1.7")
include_directories(
    ${CMAKE_BINARY_DIR}/include
    ${OpenCV_INCLUDE_DIRS}
    include
    ${PROJECT_SOURCE_DIR}/include
    ${TENSORRT_DIR}/include
    /usr/local/cuda/include
)

link_directories(
    ${PROJECT_BINARY_DIR}/lib
    /usr/local/libs
    /usr/lib
    /usr/local/cuda/lib64
    ${TENSORRT_DIR}/lib
)

# Define TensorRT libraries
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)

# Define executables
add_executable(${PROJECT_NAME} initImagebindTensorrt.cpp)
add_executable(test_engine test_engine.cpp)

# Link libraries for each executable
target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBRARIES}
    ${TENSORRT_LIBS}
    ${CUDA_LIBRARIES}
)

target_link_libraries(test_engine
    ${OpenCV_LIBRARIES}
    ${TENSORRT_LIBS}
    ${CUDA_LIBRARIES}
)